-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathCalendar.xojo_code
More file actions
2343 lines (1970 loc) · 64.7 KB
/
Calendar.xojo_code
File metadata and controls
2343 lines (1970 loc) · 64.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#tag Class
Protected Class Calendar
Inherits Canvas
#tag Event
Function MouseDown(X As Integer, Y As Integer) As Boolean
Return True
End Function
#tag EndEvent
#tag Event
Sub MouseExit()
Dim i as integer
for i = 0 to UBound(CalendarButtonClassArray)
CalendarButtonClassArray(i).mouseOver = False
next
Me.Invalidate(False)
End Sub
#tag EndEvent
#tag Event
Sub MouseMove(X As Integer, Y As Integer)
Dim i as integer
for i = 0 to UBound(CalendarButtonClassArray)
if i > 6 Then
if X >= CalendarButtonClassArray(i).LeftX AND X <= CalendarButtonClassArray(i).RightX AND Y >= CalendarButtonClassArray(i).TopY AND Y <= CalendarButtonClassArray(i).BottomY Then
CalendarButtonClassArray(i).mouseOver = True
Else
CalendarButtonClassArray(i).mouseOver = False
end if
end if
Me.Invalidate(False)
next
End Sub
#tag EndEvent
#tag Event
Sub MouseUp(X As Integer, Y As Integer)
Dim i as integer
for i = 0 to UBound(CalendarButtonClassArray)
if Keyboard.ShiftKey = True Then // Multi Selection
if AllowMultipleSelections = True Then
if X >= CalendarButtonClassArray(i).LeftX AND X <= CalendarButtonClassArray(i).RightX AND Y >= CalendarButtonClassArray(i).TopY AND Y <= CalendarButtonClassArray(i).BottomY Then
CalendarButtonClassArray(i).Selected = True
SelectedDate = New Date
// Set the correct month
if CalendarButtonClassArray(i).NextMonthMark = True Then
SelectedDate.Month = convertMonthStringToMonthNumber(NextMonth)
Elseif CalendarButtonClassArray(i).PrevMonthMark = True Then
SelectedDate.Month = convertMonthStringToMonthNumber(PreviousMonth)
end if
SelectedDate.Month = convertMonthStringToMonthNumber(SelectedMonth)
SelectedDate.Year = CDbl(SelectedYear)
SelectedDate.Day = CalendarButtonClassArray(i).Day
CalendarButtonClassArray(i).SelectedDate = SelectedDate
Calendar_Container(window).raiseThisEvent(CalendarButtonClassArray(i).SelectedDate)
Me.Invalidate(False)
end if
end if
Elseif Keyboard.ShiftKey = False Then // Single Selection
if i > 6 Then
if X >= CalendarButtonClassArray(i).LeftX AND X <= CalendarButtonClassArray(i).RightX AND Y >= CalendarButtonClassArray(i).TopY AND Y <= CalendarButtonClassArray(i).BottomY Then
deselectAll()
CalendarButtonClassArray(i).Selected = True
SelectedDate = New Date
// Set the correct month
Dim MonthToAdvance as String
if CalendarButtonClassArray(i).NextMonthMark = True Then
SelectedDate.Month = convertMonthStringToMonthNumber(NextMonth)
SelectedDate.Day = CalendarButtonClassArray(i).Day
MonthToAdvance = "Next"
Elseif CalendarButtonClassArray(i).PrevMonthMark = True Then
SelectedDate.Month = convertMonthStringToMonthNumber(PreviousMonth)
SelectedDate.Day = CalendarButtonClassArray(i).Day
MonthToAdvance = "Prev"
end if
SelectedDate.Year = CDbl(SelectedYear)
CalendarButtonClassArray(i).SelectedDate = SelectedDate
if MonthToAdvance = "Next" or MonthToAdvance = "Prev" Then
// Converting here
deselectAll()
takeUsToMonth(MonthToAdvance, SelectedDate)
Calendar_Container(window).raiseThisEvent(SelectedDate)
//
for ii as integer = 0 to UBound(CalendarButtonClassArray)
if CalendarButtonClassArray(ii).Day = SelectedDate.Day Then
CalendarButtonClassArray(ii).TransMark = True
CalendarButtonClassArray(ii).SelectedDate = SelectedDate
Else
CalendarButtonClassArray(ii).TransMark = False
End if
next ii
deselectAll()
remapSelectedToSlot()
Else
SelectedDate.Month = convertMonthStringToMonthNumber(SelectedMonth)
SelectedDate.Day = CalendarButtonClassArray(i).Day
Calendar_Container(window).raiseThisEvent(SelectedDate)
End if
Me.Invalidate(False)
end if
end if
End if
next i
// Need to flag if the date is in the current month, previous month, or next month
End Sub
#tag EndEvent
#tag Event
Sub Open()
#If TargetWin32 Then
DoubleBuffer = True
Transparent = True
EraseBackground = False
#endif
// Set Initially the Selected Date for Today's Date
Dim TodayIsTheDay as new Date
SelectedDate = TodayIsTheDay
End Sub
#tag EndEvent
#tag Event
Sub Paint(g As Graphics, areas() As REALbasic.Rect)
g.AntiAlias = True
// FILL BACKGROUND COLOR
g.ForeColor = RGB(255,255,255)
g.FillRoundRect (1,1,me.Width-2,me.Height-2,8,8)
// DRAW CANVAS BORDER OUTLINE
g.ForeColor = RGB(170,170,170)
g.PenHeight = 2
g.PenWidth = 2
#IF TargetWin32 Then
g.DrawRect(0,0,me.Width,me.Height)
#ELSE
g.DrawroundRect(0,0,me.Width,me.Height,0,0)
#ENDIF
'// DRAW GRIDLINES FOR DEBUGGING
'for q as integer = 0 to CalendarButtonClassArray.Ubound
'g.ForeColor = &cff0000
'g.DrawLine(CalendarButtonClassArray(q).LeftX, CalendarButtonClassArray(q).TopY,CalendarButtonClassArray(q).RightX, CalendarButtonClassArray(q).TopY)
'g.DrawLine(CalendarButtonClassArray(q).LeftX, CalendarButtonClassArray(q).TopY, CalendarButtonClassArray(q).LeftX, CalendarButtonClassArray(q).BottomY)
'next q
// DRAW COLUMN LINE: USER OPTION
If drawColumnLines = True Then
Dim lineWidth as Integer = 1
Dim colLineX1POS as Integer = 30
Dim colLineY1POS as Integer = 8
Dim colLineX2POS as Integer = 30
Dim colLineY2POS as Integer = 160
g.PenHeight = lineWidth
g.PenWidth = lineWidth
for i as integer = 1 to 6
g.DrawLine(colLineX1POS, colLineY1POS, colLineX2POS, colLineY2POS)
colLineX1POS = colLineX1POS + 30
colLineX2POS = colLineX1POS
next i
End If
// SET TODAYS DATE ON FIRST RUN
dim OffSet as Integer = 3
dim TwoOffset as Integer = (OffSet*2)
dim CurveSize as Integer = 6
if SelectTodayRunOnce = False Then
for i as integer = 7 to UBound(CalendarButtonClassArray)
if CalendarButtonClassArray(i).MyDate = CurrentDate Then
CalendarButtonClassArray(i).Selected = True
CalendarButtonClassArray(i).SelectedDate = CurrentDate
end if
next
SelectTodayRunOnce = True
end if
// HIGHLIGHT CALENDAR DAY SLOT WHEN SELECTED
for i as integer = 0 to UBound(CalendarButtonClassArray)
if CalendarButtonClassArray(i).Selected = True Then
if CalendarButtonClassArray(i).Day <> 0 Then
// Capture Selected Date in Date format for Custom Event
g.ForeColor = &c1261A0
#IF TargetMacOS OR TargetLinux Then
Dim theLeft as Integer = CalendarButtonClassArray(i).LeftX + 2
Dim theTop as Integer = CalendarButtonClassArray(i).TopY
Dim theWidth as Integer = CalendarButtonClassArray(i).Width
Dim theHeight as Integer = (CalendarButtonClassArray(i).Height)+1
g.FillroundRect(theLeft, theTop,theWidth,theHeight,4,4)
#ELSEIF TargetWin32 Then
Dim theLeft as Integer = CalendarButtonClassArray(i).LeftX+OffSet+1
Dim theTop as Integer = CalendarButtonClassArray(i).TopY+OffSet
Dim theWidth as Integer = CalendarButtonClassArray(i).Width-TwoOffset
Dim theHeight as Integer = CalendarButtonClassArray(i).Height-TwoOffset
g.FillRoundRect(theLeft, theTop,theWidth,theHeight,0,0)
#ENDIF
End if
End if
Next i
// MOUSE OVER HIGHLIGHT SLOT
for i as integer = 0 to UBound(CalendarButtonClassArray)
if CalendarButtonClassArray(i).mouseOver = True Then
if CalendarButtonClassArray(i).Day <> 0 Then
// Capture Selected Date in Date format for Custom Event
g.ForeColor = &c1261A0
#IF TargetMacOS OR TargetLinux Then
Dim theLeft as Integer = CalendarButtonClassArray(i).LeftX + 2
Dim theTop as Integer = CalendarButtonClassArray(i).TopY
Dim theWidth as Integer = CalendarButtonClassArray(i).Width
Dim theHeight as Integer = (CalendarButtonClassArray(i).Height) +1
g.DrawroundRect(theLeft, theTop,theWidth,theHeight,4,4)
#ELSEIF TargetWin32 Then
Dim theLeft as Integer = CalendarButtonClassArray(i).LeftX+OffSet+1
Dim theTop as Integer = CalendarButtonClassArray(i).TopY+OffSet
Dim theWidth as Integer = CalendarButtonClassArray(i).Width-TwoOffset
Dim theHeight as Integer = CalendarButtonClassArray(i).Height-TwoOffset
g.DrawRect(theLeft, theTop,theWidth,theHeight)
#ENDIF
End if
End if
Next i
// DRAW DAYS OF WEEK ABBREVIATION WORK
g.ForeColor = &c595959
g.TextFont = "System"
g.Bold = false
g.TextSize = 12
dim thisPosX, thisPosY as Integer
Dim nextPosX as Integer
for p as integer = 0 to 6
if CalMonFirstDayOfWeekBool = False Then
// CALCULATE SPACING FOR VARIABLE ABBR NAMES --> SUN - SAT
dim thisAbbrvStrW as Double = g.StringWidth(DayOfWeekArray_SS(p))
dim thisAbbrvStrH as Double = g.StringHeight(DayOfWeekArray_SS(p), 500)
dim thisSlotW as Double = CalendarButtonClassArray(p).Width
dim thisSlotH as Double = CalendarButtonClassArray(p).Height
dim thisSlotLeft as Double = CalendarButton.RightX
dim thisSlotTop as Double = CalendarButtonClassArray(p).TopY
thisPosX = thisPosX + (thisSlotW/2) - (thisAbbrvStrW/2)
thisPosY = (thisSlotH/2) + (thisAbbrvStrH/2)-2
g.DrawString(DayOfWeekArray_SS(p), thisPosX, thisPosY)
// NEXT LEFT BORDER STARTING POINT
nextPosX = nextPosX + CalendarButtonClassArray(p).RightX
thisPosX = nextPosX
Elseif CalMonFirstDayOfWeekBool = True Then
// CALCULATE SPACING FOR VARIABLE ABBR NAMES - MON - SUN
dim thisAbbrvStrW as Double = g.StringWidth(DayOfWeek_MS(p))
dim thisAbbrvStrH as Double = g.StringHeight(DayOfWeek_MS(p), 500)
dim thisSlotW as Double = CalendarButtonClassArray(p).Width
dim thisSlotH as Double = CalendarButtonClassArray(p).Height
dim thisSlotLeft as Double = CalendarButton.RightX
dim thisSlotTop as Double = CalendarButtonClassArray(p).TopY
thisPosX = thisPosX + (thisSlotW/2) - (thisAbbrvStrW/2)
thisPosY = (thisSlotH/2) + (thisAbbrvStrH/2)-2
g.DrawString(DayOfWeek_MS(p), thisPosX, thisPosY)
// NEXT LEFT BORDER STARTING POINT
nextPosX = nextPosX + CalendarButtonClassArray(p).RightX
thisPosX = nextPosX
end if
next p
// DRAW DAY NUMBER IN CALENDAR SLOT
Dim SelectMonthInt as Integer = convertMonthStringToMonthNumber(SelectedMonth)
for i as integer = 7 to UBound(CalendarButtonClassArray)
if CalendarButtonClassArray(i).Selected = True Then
if CDbl(SelectedYear) = CurrentDate.Year AND SelectMonthInt = CurrentDate.Month AND CalendarButtonClassArray(i).Day = CurrentDate.Day Then
g.bold = false
g.ForeColor = RGB(255,255,255)
Else
g.bold = false
g.ForeColor = RGB(255,255,255)
End if
elseif CalendarButtonClassArray(i).NextMonthMark = True OR CalendarButtonClassArray(i).PrevMonthMark = True Then
g.bold = false
g.ForeColor= RGB(170,170,170)
elseif CDbl(SelectedYear) = CurrentDate.Year AND SelectMonthInt = CurrentDate.Month AND CalendarButtonClassArray(i).Day = CurrentDate.Day Then
g.bold = True
g.ForeColor = &c1261A
Else
g.bold = false
g.ForeColor = &c333333
End if
// Draw Days Centered -- Windows GDI+ Is different that MacOS for centering the Calendar Day Text FYI.
#IF TargetWin32 Then
if CalendarButtonClassArray(i).Day = 0 Then
g.DrawString("",CalendarButtonClassArray(i).LeftX+13,CalendarButtonClassArray(i).TopY+17)
Else
if CalendarButtonClassArray(i).Day > 0 AND CalendarButtonClassArray(i).Day < 10 Then
g.DrawString(Str(CalendarButtonClassArray(i).day),CalendarButtonClassArray(i).LeftX+12.5,CalendarButtonClassArray(i).TopY+17)
Else
g.DrawString(Str(CalendarButtonClassArray(i).day),CalendarButtonClassArray(i).LeftX+10,CalendarButtonClassArray(i).TopY+17)
End if
End if
#ELSEIF TargetMacOS OR TargetLinux Then
if CalendarButtonClassArray(i).Day = 0 Then
g.DrawString("",CalendarButtonClassArray(i).LeftX+12.5,CalendarButtonClassArray(i).TopY+18)
Else
if CalendarButtonClassArray(i).Day > 0 AND CalendarButtonClassArray(i).Day < 10 Then
g.DrawString(Str(CalendarButtonClassArray(i).day),CalendarButtonClassArray(i).LeftX+12.5,CalendarButtonClassArray(i).TopY+17)
Else
g.DrawString(Str(CalendarButtonClassArray(i).day),CalendarButtonClassArray(i).LeftX+8.5,CalendarButtonClassArray(i).TopY+17)
End if
End if
#ENDIF
next i
End Sub
#tag EndEvent
#tag Method, Flags = &h0
Sub buildLocalizedDayOfWeekList(inLocalizationInt as Integer)
Select Case inLocalizationInt
Case 0
Localized_Monday = "Monday"
Localized_Tuesday = "Tuesday"
Localized_Wednesday = "Wednesday"
Localized_Thursday = "Thursday"
Localized_Friday = "Friday"
Localized_Saturday = "Saturday"
Localized_Sunday = "Sunday"
Case 1 // French
Localized_Monday = "Lundi"
Localized_Tuesday = "Mardi"
Localized_Wednesday = "Mercredi"
Localized_Thursday = "Jeudi"
Localized_Friday = "Vendredi"
Localized_Saturday = "Samedi"
Localized_Sunday = "Dimanche"
Case 2 // Swedish
Localized_Monday = "Måndag"
Localized_Tuesday = "Tisdag"
Localized_Wednesday = "Onsdag"
Localized_Thursday = "Torsdag"
Localized_Friday = "Fredag"
Localized_Saturday = "Lördag"
Localized_Sunday = "Söndag"
Case 3 // Italian
Localized_Monday = "Lunedì"
Localized_Tuesday = "Martedì"
Localized_Wednesday = "Mercoledì"
Localized_Thursday = "Giovedì"
Localized_Friday = "Venerdì"
Localized_Saturday = "Sabato"
Localized_Sunday = "Domenica"
Case 4 // Spanish
Localized_Monday = "Lunes"
Localized_Tuesday = "Martes"
Localized_Wednesday = "Miércoles"
Localized_Thursday = "Jueves"
Localized_Friday = "Viernes"
Localized_Saturday = "Sábado"
Localized_Sunday = "Domingo"
Case 5 // Dutch
Localized_Monday = "Maandag"
Localized_Tuesday = "Dinsdag"
Localized_Wednesday = "Woensdag"
Localized_Thursday = "Donderdag"
Localized_Friday = "Vrijdag"
Localized_Saturday = "Zaterdag"
Localized_Sunday = "Zondag"
Case 6 // German
Localized_Monday = "Montag"
Localized_Tuesday = "Dienstag"
Localized_Wednesday = "Mittwoch"
Localized_Thursday = "Donnerstag"
Localized_Friday = "Freitag"
Localized_Saturday = "Samstag"
Localized_Sunday = "Sonntag"
Case 7 // Afrikaans
Localized_Monday = "Maandag"
Localized_Tuesday = "Dinsdag"
Localized_Wednesday = "Woensdag"
Localized_Thursday = "Donderdag"
Localized_Friday = "Vrydag"
Localized_Saturday = "Saterdag"
Localized_Sunday = "Sondag"
Case 8 // Polish
Localized_Monday = "Poniedziałek"
Localized_Tuesday = "Wtorek"
Localized_Wednesday = "Środa"
Localized_Thursday = "Czwartek"
Localized_Friday = "Piątek"
Localized_Saturday = "Sobota"
Localized_Sunday = "Niedziela"
Case 9 // Portuguese
Localized_Monday = "Segunda-feira"
Localized_Tuesday = "Terça-feira"
Localized_Wednesday = "Quarta-feira"
Localized_Thursday = "Quinta-feira"
Localized_Friday = "Sexta-feira"
Localized_Saturday = "Sábado"
Localized_Sunday = "Domingo"
End Select
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub buildLocalizedDayOfWeek_Arrays(inLocalizationInt as Integer)
Select Case inLocalizationInt
Case 0
////////////////////////////
/////// English ///////
///////////////////////////
//Sat - Sun
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Su"
DayOfWeekArray_SS.Append "Mo"
DayOfWeekArray_SS.Append "Tu"
DayOfWeekArray_SS.Append "We"
DayOfWeekArray_SS.Append "Th"
DayOfWeekArray_SS.Append "Fr"
DayOfWeekArray_SS.Append "Sa"
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Mo"
DayOfWeek_MS.Append "Tu"
DayOfWeek_MS.Append "We"
DayOfWeek_MS.Append "Th"
DayOfWeek_MS.Append "Fr"
DayOfWeek_MS.Append "Sa"
DayOfWeek_MS.Append "Su"
Case 1 // French
//Sat - Sun
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Dim"
DayOfWeekArray_SS.Append "Lun"
DayOfWeekArray_SS.Append "Mar"
DayOfWeekArray_SS.Append "Mer"
DayOfWeekArray_SS.Append "Jeu"
DayOfWeekArray_SS.Append "Ven"
DayOfWeekArray_SS.Append "Sam"
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Lun"
DayOfWeek_MS.Append "Mar"
DayOfWeek_MS.Append "Mer"
DayOfWeek_MS.Append "Jeu"
DayOfWeek_MS.Append "Ven"
DayOfWeek_MS.Append "Sam"
DayOfWeek_MS.Append "Dim"
Case 2 // Swedish
//Sat - Sun
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Sön"
DayOfWeekArray_SS.Append "Mån"
DayOfWeekArray_SS.Append "Tis"
DayOfWeekArray_SS.Append "Ons"
DayOfWeekArray_SS.Append "Tor"
DayOfWeekArray_SS.Append "Fre"
DayOfWeekArray_SS.Append "Lör"
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Mån"
DayOfWeek_MS.Append "Tis"
DayOfWeek_MS.Append "Ons"
DayOfWeek_MS.Append "Tor"
DayOfWeek_MS.Append "Fre"
DayOfWeek_MS.Append "Lör"
DayOfWeek_MS.Append "Sön"
Case 3 // Italian
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Dom"
DayOfWeekArray_SS.Append "Mar"
DayOfWeekArray_SS.Append "Mer"
DayOfWeekArray_SS.Append "Gio"
DayOfWeekArray_SS.Append "Ven"
DayOfWeekArray_SS.Append "Sab"
DayOfWeekArray_SS.Append "Lör"
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Lun"
DayOfWeek_MS.Append "Mar"
DayOfWeek_MS.Append "Mer"
DayOfWeek_MS.Append "Gio"
DayOfWeek_MS.Append "Ven"
DayOfWeek_MS.Append "Sab"
DayOfWeek_MS.Append "Dom"
Case 4 // Spanish
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Do" // Sunday
DayOfWeekArray_SS.Append "Lu"
DayOfWeekArray_SS.Append "Ma"
DayOfWeekArray_SS.Append "Mi"
DayOfWeekArray_SS.Append "Ju"
DayOfWeekArray_SS.Append "Vi"
DayOfWeekArray_SS.Append "Sá" // Saturday
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Lu" // Monday
DayOfWeek_MS.Append "Ma"
DayOfWeek_MS.Append "Mi"
DayOfWeek_MS.Append "Ju"
DayOfWeek_MS.Append "Vi"
DayOfWeek_MS.Append "Sá"
DayOfWeek_MS.Append "Do" // Sunday
Case 5 // Dutch
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Zon" // Sunday
DayOfWeekArray_SS.Append "Maa"
DayOfWeekArray_SS.Append "Din"
DayOfWeekArray_SS.Append "Woe"
DayOfWeekArray_SS.Append "Don"
DayOfWeekArray_SS.Append "Vry"
DayOfWeekArray_SS.Append "Zat" // Saturday
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Maa" // Monday
DayOfWeek_MS.Append "Din"
DayOfWeek_MS.Append "Woe"
DayOfWeek_MS.Append "Don"
DayOfWeek_MS.Append "Vry"
DayOfWeek_MS.Append "Zat"
DayOfWeek_MS.Append "Zon" // Sunday
Case 6 // German
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "So" // Sunday
DayOfWeekArray_SS.Append "Mo"
DayOfWeekArray_SS.Append "Di"
DayOfWeekArray_SS.Append "Mi"
DayOfWeekArray_SS.Append "Do"
DayOfWeekArray_SS.Append "Fr"
DayOfWeekArray_SS.Append "Sa" // Saturday
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Mo" // Monday
DayOfWeek_MS.Append "Di"
DayOfWeek_MS.Append "Mi"
DayOfWeek_MS.Append "Do"
DayOfWeek_MS.Append "Fr"
DayOfWeek_MS.Append "Sa"
DayOfWeek_MS.Append "So" // Sunday
Case 7 // Africaans
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Son" // Sunday
DayOfWeekArray_SS.Append "Maa"
DayOfWeekArray_SS.Append "Din"
DayOfWeekArray_SS.Append "Woe"
DayOfWeekArray_SS.Append "Don"
DayOfWeekArray_SS.Append "Vry"
DayOfWeekArray_SS.Append "Sat" // Saturday
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Maa" // Monday
DayOfWeek_MS.Append "Din"
DayOfWeek_MS.Append "Woe"
DayOfWeek_MS.Append "Don"
DayOfWeek_MS.Append "Vry"
DayOfWeek_MS.Append "Sat"
DayOfWeek_MS.Append "Son" // Sunday
Case 8 // Polish
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Ni" // Sunday
DayOfWeekArray_SS.Append "Pn"
DayOfWeekArray_SS.Append "Wt"
DayOfWeekArray_SS.Append "Śr"
DayOfWeekArray_SS.Append "Czw"
DayOfWeekArray_SS.Append "Pt"
DayOfWeekArray_SS.Append "Sob" // Saturday
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Pn" // Monday
DayOfWeek_MS.Append "Wt"
DayOfWeek_MS.Append "Śr"
DayOfWeek_MS.Append "Czw"
DayOfWeek_MS.Append "Pt"
DayOfWeek_MS.Append "Sob"
DayOfWeek_MS.Append "Ni" // Sunday
Case 9 // Portuguese
Redim DayOfWeekArray_SS(-1)
DayOfWeekArray_SS.Append "Dom" // Sunday
DayOfWeekArray_SS.Append "Seg"
DayOfWeekArray_SS.Append "Ter"
DayOfWeekArray_SS.Append "Qua"
DayOfWeekArray_SS.Append "Qui"
DayOfWeekArray_SS.Append "Sex"
DayOfWeekArray_SS.Append "Sab" // Saturday
// Mon - Sun
Redim DayOfWeek_MS(-1)
DayOfWeek_MS.Append "Seg" // Monday
DayOfWeek_MS.Append "Ter"
DayOfWeek_MS.Append "Qua"
DayOfWeek_MS.Append "Qui"
DayOfWeek_MS.Append "Sex"
DayOfWeek_MS.Append "Sab"
DayOfWeek_MS.Append "Dom" // Sunday
End Select
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Sub buildLocalizedMonthList(inLocalizationInt as Integer)
Select Case inLocalizationInt
Case 0
Localized_January = "January"
Localized_February = "February"
Localized_March = "March"
Localized_April = "April"
Localized_May = "May"
Localized_June = "June"
Localized_July = "July"
Localized_August = "August"
Localized_September = "September"
Localized_October = "October"
Localized_November = "November"
Localized_December = "December"
Case 1 // French
Localized_January = "Janvier"
Localized_February = "Février"
Localized_March = "Mars"
Localized_April = "Avril"
Localized_May = "Mai"
Localized_June = "Juin"
Localized_July = "Juillet"
Localized_August = "Août"
Localized_September = "Septembre"
Localized_October = "Octobre"
Localized_November = "Novembre"
Localized_December = "Décembre"
Case 2 // Swedish
Localized_January = "Januari"
Localized_February = "Februari"
Localized_March = "Mars"
Localized_April = "April"
Localized_May = "Maj"
Localized_June = "Juni"
Localized_July = "Juli"
Localized_August = "Augusti"
Localized_September = "September"
Localized_October = "Oktober"
Localized_November = "November"
Localized_December = "December"
Case 3 // Italian
Localized_January = "Gennaio"
Localized_February = "Febbraio"
Localized_March = "Marzo"
Localized_April = "Aprile"
Localized_May = "Maggio"
Localized_June = "Giugno"
Localized_July = "Luglio"
Localized_August = "Agosto"
Localized_September = "Settembre"
Localized_October = "Ottobre"
Localized_November = "Novembre"
Localized_December = "Dicembre"
Case 4 // Spanish
Localized_January = "Enero"
Localized_February = "Febrero"
Localized_March = "Marzo"
Localized_April = "Abril"
Localized_May = "Mayo"
Localized_June = "Junio"
Localized_July = "Julio"
Localized_August = "Agosto"
Localized_September = "Septiembre"
Localized_October = "Octubre"
Localized_November = "Noviembre"
Localized_December = "Diciembre"
Case 5 // Dutch
Localized_January = "Januari"
Localized_February = "Februari"
Localized_March = "Maart"
Localized_April = "April"
Localized_May = "Mei"
Localized_June = "Juni"
Localized_July = "Juli"
Localized_August = "Augustus"
Localized_September = "September"
Localized_October = "Oktober"
Localized_November = "November"
Localized_December = "December"
Case 6 // German
Localized_January = "Januar"
Localized_February = "Februar"
Localized_March = "März"
Localized_April = "April"
Localized_May = "Mai"
Localized_June = "Juni"
Localized_July = "Juli"
Localized_August = "August"
Localized_September = "September"
Localized_October = "Oktober"
Localized_November = "November"
Localized_December = "Dezember"
Case 7 // Afrikaans
Localized_January = "Januarie"
Localized_February = "Februarie"
Localized_March = "Maart"
Localized_April = "April"
Localized_May = "Mei"
Localized_June = "Junie"
Localized_July = "Julie"
Localized_August = "Augustus"
Localized_September = "September"
Localized_October = "Oktober"
Localized_November = "November"
Localized_December = "Desember"
Case 8 // Polish
Localized_January = "Styczeń"
Localized_February = "Luty"
Localized_March = "Marzec"
Localized_April = "Kwiecień"
Localized_May = "Maj"
Localized_June = "Czerwiec"
Localized_July = "Lipiec"
Localized_August = "Sierpień"
Localized_September = "Wrzesień"
Localized_October = "Październik"
Localized_November = "Listopad"
Localized_December = "Grudzień"
Case 9 // Portuguese
Localized_January = "Janeiro"
Localized_February = "Fevereiro"
Localized_March = "Março"
Localized_April = "Abril"
Localized_May = "Maio"
Localized_June = "Junho"
Localized_July = "Julho"
Localized_August = "Agosto"
Localized_September = "Setembro"
Localized_October = "Outubro"
Localized_November = "Novembro"
Localized_December = "Dezembro"
End Select
End Sub
#tag EndMethod
#tag Method, Flags = &h21
Private Function calcCenturyNumber(inYear as Integer) As Integer
// Map Century Number
Select Case inYear
Case 1900 to 1999
Return 0
Case 2000 to 2099
Return 1
Case 2100 to 2199
Return 3
Case 2200 to 2299
Return 5
End Select
End Function
#tag EndMethod
#tag Method, Flags = &h21
Private Function calcHowManyCalSlotsAvailable(inStartingSlot as Integer, inEndingSlot as Integer, inSpacesAvailable as Integer) As Integer
// This will calculate how many available Spaces we have for next or previous month Calendar day assignments
for x as integer = inStartingSlot to inEndingSlot
if CalendarButtonClassArray(x).Day = 0 Then
inSpacesAvailable = inSpacesAvailable + 1
end if
next x
Return inSpacesAvailable
End Function
#tag EndMethod
#tag Method, Flags = &h0
Function calcLeapYear(inYear as Integer) As boolean
Return (((inYear MOD 4)=0) AND ((inYear MOD 100)<>0)) OR (inYear MOD 400)=0
End Function
#tag EndMethod
#tag Method, Flags = &h21
Private Function calcMonthNumber(inMonth as String) As Integer
//If inMonth = Localized_February AND LeapYearBool = True OR inMonth = Localized_August Then
//Return 0
//Elseif inMonth = Localized_February AND LeapYearBool = False Then
//Return 0
//Elseif inMonth = Localized_November OR inMonth = Localized_March Then
//Return 1
//Elseif inMonth = Localized_June Then
//Return 2
//ElseIf inMonth = Localized_September OR inMonth = Localized_December Then
//Return 3
//ElseIf inMonth = Localized_January AND LeapYearBool = True OR inMonth = Localized_April OR inMonth = Localized_July Then
//Return 4
//Elseif inMonth = Localized_January AND LeapYearBool = False OR inMonth = Localized_October Then
//Return 5
//Elseif inMonth = Localized_May Then
//Return 6
//End if
//
// FIX FROM JON OGEN
If inMonth = Localized_February AND LeapYearBool = True OR inMonth = Localized_August Then
Return 0
Elseif (inMonth = Localized_February AND Not LeapYearBool) OR inMonth = Localized_November OR inMonth = Localized_March Then
Return 1
Elseif inMonth = Localized_June Then
Return 2
ElseIf inMonth = Localized_September OR inMonth = Localized_December Then
Return 3
ElseIf inMonth = Localized_January AND LeapYearBool = True OR inMonth = Localized_April OR inMonth = Localized_July Then
Return 4
Elseif inMonth = Localized_January AND LeapYearBool = False OR inMonth = Localized_October Then
Return 5
Elseif inMonth = Localized_May Then
Return 6
End if
End Function
#tag EndMethod
#tag Method, Flags = &h0
Function calculate1stDayOfMonth() As String
// Need to Find out which Day of the Week this Month's 1st Day starts on
Dim thisYear as Integer = Cdbl(SelectedYear)
LeapYearBool = calcLeapYear(thisYear)
// Calculate to get Weekday Number
Dim WeekdayNum as integer = (CenturyNumber + YearNumber + MonthNumber)
DIM CalcWeekDayNum as Integer = WeekdayNum Mod 7
// Map Weekday Number to Weekday String
FirstWeekday = getDayOfWeekString(CalcWeekDayNum)
Return FirstWeekday
End Function
#tag EndMethod
#tag Method, Flags = &h0
Sub calculateMonth(inMonth as String)
// Get Month Number
MonthNumber = calcMonthNumber(inMonth)
End Sub
#tag EndMethod
#tag Method, Flags = &h0
Function calculateYear(inYear as String) As Integer
// Expect String from PopUp Menu but needs to convert to Integer
Dim InYearInt as Integer = CDbl(inYear)
LeapYearBool = calcLeapYear(InYearInt)
// Year Number
YearNumber = calcYearNumber(inYear)
If YearNumber = -1 Then
// NOT A VALID YEAR
Return -1
End If
End Function
#tag EndMethod
#tag Method, Flags = &h21
Private Function calcYearNumber(inYear as String) As Integer
// PUT BOUNDS AROUND YEAR SELECTION
Dim CalcYearFinal, theYear as integer
theYear = CDbl(inYear)
If theYear < StartYear OR theYear > EndYear Then
Return -1
End If
Dim TrimFirstTwoDigits as String = inYear.Right(2)
Dim Year as Integer = CDbl(TrimFirstTwoDigits)
Dim CalcYearNum as Integer
CalcYearNum = Year + Year / 4
CalcYearFinal = CalcYearNum mod 7
Return CalcYearFinal
End Function
#tag EndMethod